<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {

        $this->call('SentrySeeder');
        // $this->call(UsersTableSeeder::class);
        // 清空数据
        DB::table('users')->delete();
        DB::table('groups')->delete();
        DB::table('users_groups')->delete();

        // 创建用户
        Sentry::getUserProvider()->create(array(
            'email'      => '289650682@qq.com',
            'password'   => "123456",
            'first_name' => '光芒',
            'last_name'  => '史',
            'activated'  => 1,
        ));

        // 创建用户组
        Sentry::getGroupProvider()->create(array(
            'name'        => 'Admin',
            'permissions' => ['admin' => 1],
        ));

        // 将用户加入用户组
        $adminUser  = Sentry::getUserProvider()->findByLogin('289650682@qq.com');
        $adminGroup = Sentry::getGroupProvider()->findByName('Admin');
        $adminUser->addGroup($adminGroup);
    }
}
